import { ElMessage } from 'element-plus';

export const getMonth = (i) => {
  switch (i) {
    case 1: return '一';
    case 2: return '二';
    case 3: return '三';
    case 4: return '四';
    case 5: return '五';
    case 6: return '六';
    case 7: return '七';
    case 8: return '八';
    case 9: return '九';
    case 10: return '十';
    case 11: return '十一'
    case 12: return '十二'
  }
}

/**
 * 提示信息
 * @param { string } message 
 * @param { string } type 
 */
export const showMsg = async (message, type = 'error') => {
  ElMessage({ type, message });
}

/**
 * 保留对象的key，置空对象key对应的值
 * @param { Object } obj 
 */
export const resetObj = async (obj) => {
  if (typeof obj !== 'object') throw new Error('入参非对象');
  for(let key in obj) obj[key] = null;
}

/**
 * 将source的值复制到object
 * @param { Object } object 目的对象
 * @param { Object } source 源对象
 */
export const copyAttr = async (object, source) => {
  if (typeof object !== 'object') throw new Error('目标参数非对象');
  if (typeof source !== 'object') throw new Error('来源参数非对象');
  for(let key in source) object[key] = source[key];
}

